package com.wan37.logic.utils;

import com.wan37.common.xml.XMLUtils;
import com.wan37.logic.domain.vo.RoleLevelVO;
import org.dom4j.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * @author : luoyong
 * @date : 2020-06-03 15:48
 **/
@Component
public class RoleLevelUtil {

    private static final Logger logger = LoggerFactory.getLogger(RoleLevelUtil.class);

    /**
     * 角色等级对应的数值
     */
    public Map<String, RoleLevelVO> userRoleLevelMap = new HashMap<>();

    /**
     * 用户角色等级数值集合
     *
     * @param path
     */
    public void readLevelXml(String path) {
        XmlUtil<RoleLevelVO> xmlUtil = new XmlUtil<>();
        List<RoleLevelVO> roleLevelVOList = xmlUtil.getXmlFileValues(path, RoleLevelVO.class);
        for (RoleLevelVO roleLevelVO : roleLevelVOList) {
            userRoleLevelMap.put(roleLevelVO.getId(), roleLevelVO);
        }
        logger.info("用户角色等级数值Map集合配置完成！！！！！");
    }
}
